
package org.spp.utilities.comparators;

import org.spp.voronoi.Edge;

import java.util.Comparator;

/**
 * MaxDistEdgeComparator.java
 * @author Ilio Catallo, Eleonora Ciceri
 * @version 1.0
 * @see Point
 * 
 * Description: the class compares two edges and orders them in a decreasing order
 *              with respect to the minDistance value
 * 
 * Date: Jul 15, 2011
 */
public class MaxDistEdgeComparator implements Comparator<Edge>{

    /**
     * Method that orders edges in a decreasing order with respect to the minDistance.
     * A value of 0 indicates that the two edges have the same minDistance; a value
     * of -1 indicates that the first edge's minDistance is bigger than the second 
     * edge's one; a value of 1 indicates that the first edge's minDistance is smaller 
     * than the second edge's one
     * @return compareResult
     */
    @Override
    public int compare(Edge e1, Edge e2){
        // Variables
        double c1 = e1.getDistanceCoefficients()[1];
        double c2 = e2.getDistanceCoefficients()[1];        
        
        if (c1 > c2)
            return -1;
        
        if (c1 < c2)
            return 1;
        
        return 0;           
    }
    
}
